/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import com.openbrew.openbrewrf.views.BeerView;
import com.openbrew.openbrewrf.views.BrewView;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "TastePanelBeer")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TastePanelBeer.findAll", query = "SELECT t FROM TastePanelBeer t"),
    @NamedQuery(name = "TastePanelBeer.findByTpbid", query = "SELECT t FROM TastePanelBeer t WHERE t.tpbid = :tpbid"),
    @NamedQuery(name = "TastePanelBeer.findByTPBAcetaldehyde", query = "SELECT t FROM TastePanelBeer t WHERE t.tPBAcetaldehyde = :tPBAcetaldehyde"),
    @NamedQuery(name = "TastePanelBeer.findByTPBIsoamyl", query = "SELECT t FROM TastePanelBeer t WHERE t.tPBIsoamyl = :tPBIsoamyl"),
    @NamedQuery(name = "TastePanelBeer.findByTPBDiacetyl", query = "SELECT t FROM TastePanelBeer t WHERE t.tPBDiacetyl = :tPBDiacetyl"),
    @NamedQuery(name = "TastePanelBeer.findByTpbdms", query = "SELECT t FROM TastePanelBeer t WHERE t.tpbdms = :tpbdms"),
    @NamedQuery(name = "TastePanelBeer.findByTPBOxidized", query = "SELECT t FROM TastePanelBeer t WHERE t.tPBOxidized = :tPBOxidized"),
    @NamedQuery(name = "TastePanelBeer.findByTPBInfected", query = "SELECT t FROM TastePanelBeer t WHERE t.tPBInfected = :tPBInfected"),
    @NamedQuery(name = "TastePanelBeer.findByTPBNotes", query = "SELECT t FROM TastePanelBeer t WHERE t.tPBNotes = :tPBNotes"),
    @NamedQuery(name = "TastePanelBeer.findByBatchID", query = "SELECT t FROM TastePanelBeer t WHERE t.tPBBatch.bid = ?1")})
public class TastePanelBeer implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "TPBID")
    private Integer tpbid;
    @Basic(optional = false)
    @NotNull
    @Column(name = "TPBAcetaldehyde")
    private boolean tPBAcetaldehyde;
    @Basic(optional = false)
    @NotNull
    @Column(name = "TPBIsoamyl")
    private boolean tPBIsoamyl;
    @Basic(optional = false)
    @NotNull
    @Column(name = "TPBDiacetyl")
    private boolean tPBDiacetyl;
    @Basic(optional = false)
    @NotNull
    @Column(name = "TPBDMS")
    private boolean tpbdms;
    @Basic(optional = false)
    @NotNull
    @Column(name = "TPBOxidized")
    private boolean tPBOxidized;
    @Basic(optional = false)
    @NotNull
    @Column(name = "TPBInfected")
    private boolean tPBInfected;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 500)
    @Column(name = "TPBNotes")
    private String tPBNotes;
    @JoinColumn(name = "TPBBeer", referencedColumnName = "BId", nullable=true)
    @ManyToOne(optional = true)
    private BeerView tPBBeer;
    @JoinColumn(name = "TPBBatch", referencedColumnName = "BID", nullable=true)
    @ManyToOne(optional = true)
    private BrewView tPBBatch;
    @JoinColumn(name = "TPBPkgType", referencedColumnName = "PackageTypeID", nullable=true)
    @ManyToOne(optional = true)
    private PackageType tPBPkgType;
    @OneToMany(mappedBy = "tastePanelBeerID1")
    private Collection<TastePanel> tastePanelCollection1;
    @OneToMany(mappedBy = "tastePanelBeerID2")
    private Collection<TastePanel> tastePanelCollection2;
    @OneToMany(mappedBy = "tastePanelBeerID3")
    private Collection<TastePanel> tastePanelCollection3;

    public TastePanelBeer() {
    }

    public TastePanelBeer(Integer tpbid) {
        this.tpbid = tpbid;
    }

    public TastePanelBeer(Integer tpbid, boolean tPBAcetaldehyde, boolean tPBIsoamyl, boolean tPBDiacetyl, boolean tpbdms, boolean tPBOxidized, boolean tPBInfected, String tPBNotes) {
        this.tpbid = tpbid;
        this.tPBAcetaldehyde = tPBAcetaldehyde;
        this.tPBIsoamyl = tPBIsoamyl;
        this.tPBDiacetyl = tPBDiacetyl;
        this.tpbdms = tpbdms;
        this.tPBOxidized = tPBOxidized;
        this.tPBInfected = tPBInfected;
        this.tPBNotes = tPBNotes;
    }

    public Integer getTpbid() {
        return tpbid;
    }

    public void setTpbid(Integer tpbid) {
        this.tpbid = tpbid;
    }

    public BeerView getTPBBeer() {
        return tPBBeer;
    }

    public void setTPBBeer(BeerView tPBBeer) {
        if(tPBBeer.getbId()!=null){
            this.tPBBeer = tPBBeer;
        }
    }

    public BrewView getTPBBatch() {
        return tPBBatch;
    }

    public void setTPBBatch(BrewView tPBBatch) {
        if(tPBBatch.getBid()!=null){
            this.tPBBatch = tPBBatch;
        }
    }

    public PackageType getTPBPkgType() {
        return tPBPkgType;
    }

    public void setTPBPkgType(PackageType tPBPkgType) {
        if(tPBPkgType.getPackageTypeID()!=null){
            this.tPBPkgType = tPBPkgType;
        }
    }

    public boolean getTPBAcetaldehyde() {
        return tPBAcetaldehyde;
    }

    public void setTPBAcetaldehyde(boolean tPBAcetaldehyde) {
        this.tPBAcetaldehyde = tPBAcetaldehyde;
    }

    public boolean getTPBIsoamyl() {
        return tPBIsoamyl;
    }

    public void setTPBIsoamyl(boolean tPBIsoamyl) {
        this.tPBIsoamyl = tPBIsoamyl;
    }

    public boolean getTPBDiacetyl() {
        return tPBDiacetyl;
    }

    public void setTPBDiacetyl(boolean tPBDiacetyl) {
        this.tPBDiacetyl = tPBDiacetyl;
    }

    public boolean getTpbdms() {
        return tpbdms;
    }

    public void setTpbdms(boolean tpbdms) {
        this.tpbdms = tpbdms;
    }

    public boolean getTPBOxidized() {
        return tPBOxidized;
    }

    public void setTPBOxidized(boolean tPBOxidized) {
        this.tPBOxidized = tPBOxidized;
    }

    public boolean getTPBInfected() {
        return tPBInfected;
    }

    public void setTPBInfected(boolean tPBInfected) {
        this.tPBInfected = tPBInfected;
    }

    public String getTPBNotes() {
        return tPBNotes;
    }

    public void setTPBNotes(String tPBNotes) {
        this.tPBNotes = tPBNotes;
    }

    @XmlTransient
    public Collection<TastePanel> getTastePanelCollection1() {
        return tastePanelCollection1;
    }

    public void setTastePanelCollection1(Collection<TastePanel> tastePanelCollection1) {
        this.tastePanelCollection1 = tastePanelCollection1;
    }

    @XmlTransient
    public Collection<TastePanel> getTastePanelCollection2() {
        return tastePanelCollection2;
    }

    public void setTastePanelCollection2(Collection<TastePanel> tastePanelCollection2) {
        this.tastePanelCollection2 = tastePanelCollection2;
    }

    @XmlTransient
    public Collection<TastePanel> getTastePanelCollection3() {
        return tastePanelCollection3;
    }

    public void setTastePanelCollection3(Collection<TastePanel> tastePanelCollection3) {
        this.tastePanelCollection3 = tastePanelCollection3;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tpbid != null ? tpbid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TastePanelBeer)) {
            return false;
        }
        TastePanelBeer other = (TastePanelBeer) object;
        if ((this.tpbid == null && other.tpbid != null) || (this.tpbid != null && !this.tpbid.equals(other.tpbid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.TastePanelBeer[ tpbid=" + tpbid + " ]";
    }
    
}
